#!/bin/bash
device=$1
cd ~/server/ota_rr
git pull origin master
if [ ! -f "$deivce.xml" ];then
  cp example_device.xml ${device}.xml
  sed -i "s/-device-/$device/g" $device.xml
  git add $device.xml
fi

oldzip=$(grep "<Filename>ResurrectionRemix-N-" $device.xml  | sed -e 's|</\?Filename>||g')
oldzip=${oldzip##* }

newzip=$2
echo "oldzip=$oldzip newzip=$newzip"
sed -i "s/$oldzip/$newzip/g" $device.xml
cd ~/server/ota_rr
echo "OTA Update for RR $device $(date +%Y%m%d) Build" > ./rrota
git commit -as -F ./rrota
git pull --no-edit origin master;
git push origin master
cd -
rm -fv ./rrota

